package com.im.app.controller;


import org.jim.core.http.HttpRequest;
import org.jim.core.http.HttpResponse;
import org.jim.core.packets.HttpReqBody;
import org.jim.server.protocol.http.annotation.RequestPath;
import org.jim.server.util.HttpResps;


@RequestPath(value = "/im")
public class ImController extends BaseController {

    @RequestPath("/test")
    public HttpResponse test(HttpRequest request)throws Exception {
        HttpResponse httpResponse=HttpResps.json(request, "123");
        return httpResponse;
    }
    /**
     * 查询用户
     * */
    @RequestPath(value = "/getUserInfo")
    public HttpResponse getUserInfo(HttpRequest request, HttpReqBody httpReqBody)throws Exception {
        httpReqBody.setOperation(1);
        return getHttPacket(request,httpReqBody);
    }
    /**
     * 查询客服会话列表
     * */
    @RequestPath(value = "/getConversations")
    public HttpResponse getConversations(HttpRequest request, HttpReqBody httpReqBody)throws Exception {
        httpReqBody.setOperation(2);
        return  getHttPacket(request,httpReqBody);
    }
    /**
     * 撤回消息
     * */
    @RequestPath(value = "/revokeMessage")
    public HttpResponse cancelChatLog(HttpRequest request, HttpReqBody httpReqBody)throws Exception {
        httpReqBody.setOperation(3);
        return getHttPacket(request,httpReqBody);
    }
    /**
     * 未读数清除
     *
     * */
    @RequestPath(value ="/clearUnreadCount")
    public HttpResponse clearUnreadCount(HttpRequest request, HttpReqBody httpReqBody) throws Exception {
        httpReqBody.setOperation(4);
        return getHttPacket(request,httpReqBody);

    }
    /**
     * 会话置顶
     *
     * */
    @RequestPath(value ="/updateIsPinned")
    public HttpResponse updateIsPinned(HttpRequest request, HttpReqBody httpReqBody) throws Exception {
        httpReqBody.setOperation(5);
        return getHttPacket(request,httpReqBody);

    }
    /**
     * 清除消息记录
     *
     * */
    @RequestPath(value ="/clearChatLog")
    public HttpResponse clearChatLog(HttpRequest request, HttpReqBody httpReqBody) throws Exception {
        httpReqBody.setOperation(6);
        return getHttPacket(request,httpReqBody);

    }
    /**
     * 清除会话
     *
     * */
    @RequestPath(value ="/clearConversations")
    public HttpResponse clearConversations(HttpRequest request, HttpReqBody httpReqBody) throws Exception {
        httpReqBody.setOperation(7);
        return getHttPacket(request,httpReqBody);
    }

    /**
     * 查询消息记录
     *
     * */
    @RequestPath(value ="/getHistoryMessage")
    public HttpResponse getHistoryMessage(HttpRequest request, HttpReqBody httpReqBody) throws Exception {
        httpReqBody.setOperation(8);
        return getHttPacket(request,httpReqBody);
    }


}
